﻿@model IEnumerable<ElCharro01.Models.Product>
@using ElCharro01.Helpers
@{
    ViewBag.Title = "ShowSelectedProducts";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
<div class="paddalo">
    <h2 class="centered">
        Mostra Prodotti: @ViewBag.CategoryName @ViewBag.ClothingTypeName</h2>
    <table>
        <tr>
            <th>
                Nome
            </th>
            <th>
                Descrizione
            </th>
            <th>
                Categoria
            </th>
            <th>
                Tipo Abbigliamento
            </th>
            <th colspan="2">
            </th>
        </tr>
        @foreach (var item in Model)
        {
            if (item.Variant.Count() >= 1)
            {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Nome)
                </td>
                <td>
                    @Html.Truncate(item.Descrizione,10)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Category.Nome)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ClothingType.Nome)
                </td>
                <td>
                    <a href="@Url.Action("Detail", "Variant", new { id = item.Variant.First().ID })">
                        <img height="110" width="110" src="/Content/Images/Raw/@item.Variant.First().Image.First().Path" alt="@item.Nome" />
                    </a>
                </td>
                <td>
                    @Html.ActionLink("Aggiungi Variante", "Create", "Variant", new { id = item.ID }, new { })
                    |
                    @Html.ActionLink("Mostra Varianti", "ShowVariantOfProduct", "Variant", new { ProductID = item.ID }, new { })
                    |
                    @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
                    @Html.ActionLink("Delete", "Delete", new { id = item.ID })
                </td>
            </tr>
            }
        }
    </table>
</div>
